<html>
<head><meta charset="utf-8"><title>comment inside template · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html">comment inside template</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209848045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/comment%20inside%20template/near/209848045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> JOE1994 <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html#209848045">(Sep 11 2020 at 23:47)</a>:</h4>
<p>Hello <span aria-label="crab" class="emoji emoji-1f980" role="img" title="crab">:crab:</span> , is it possible for the <code>asm!</code> template string to contain comments? I'm trying to port the following the following to <code>asm!</code> and the <code>llvm_asm!</code> macro contains a comment. I'm not sure whether I should remove the comment block in the new <code>asm!</code> template string or not.</p>
<div class="codehilite"><pre><span></span><code><span class="w">            </span><span class="n">llvm_asm</span><span class="o">!</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="s">&quot;</span>
<span class="s">            mov sp, r0   /* Set the stack pointer to _estack */&quot;</span><span class="w"></span>
<span class="w">            </span>:
            : <span class="s">&quot;{r0}&quot;</span><span class="p">((</span><span class="n">_estack</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">())</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">u32</span><span class="p">)</span><span class="w"></span>
<span class="w">            </span>:
            : <span class="s">&quot;volatile&quot;</span><span class="w"> </span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="209848677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/comment%20inside%20template/near/209848677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html#209848677">(Sep 12 2020 at 00:00)</a>:</h4>
<p>The generally preferred way is to split the template string across multiple lines and put the comments outside.</p>



<a name="209848720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/comment%20inside%20template/near/209848720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html#209848720">(Sep 12 2020 at 00:00)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="n">asm</span><span class="o">!</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;mov {0}, {1}&quot;</span><span class="p">,</span><span class="w"> </span><span class="c1">// comment</span>
<span class="w">        </span><span class="s">&quot;add {0}, {number}&quot;</span><span class="p">,</span><span class="w"> </span><span class="c1">// comment</span>
<span class="w">        </span><span class="n">out</span><span class="p">(</span><span class="n">reg</span><span class="p">)</span><span class="w"> </span><span class="n">o</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="k">in</span><span class="p">(</span><span class="n">reg</span><span class="p">)</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">number</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="209848732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/comment%20inside%20template/near/209848732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html#209848732">(Sep 12 2020 at 00:00)</a>:</h4>
<p>You can also use <code>/* */</code> comments inside the string, that's handled by the assembler</p>



<a name="209850226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/comment%20inside%20template/near/209850226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> JOE1994 <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/comment.20inside.20template.html#209850226">(Sep 12 2020 at 00:31)</a>:</h4>
<p>Thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>